
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>

<title>Phonology</title>
<script src="js/environments.js" type="text/javascript"></script>
<style type="text/css">
	
	table {width:100px;}
	table th {font-size:30px;}
	.selector li {float:left;padding:15px;list-style:none;}
	.selector {border:0px black solid;height:100px;}
	
	
</style>

</head>

<body>
<h1>Phonology</h1>
<strong>I wrote this in php & javascript. It analyzes the phonetic contexts of whatever words you enter. It currently does not support unicode (i.e. use of the IPA). If anyone has any ideas on how to make that happen, let me know!</strong><br />
<br />
<br />
<a href="https://code.google.com/p/phonology/source/browse/" target="_blank" style="float:left;">the source code</a>
<br />
<br />

<fieldset><legend>Type in your words below: (separate each word with a single space)</legend>

  <form action="" method="POST" name="wordInput">
 <!--   <ul id="myTags"></ul> -->
    <input type="text" name='words' style="width:500px;"/>
    <input type="submit" value="Submit" name="submit"/>
  </form>


</fieldset>

<?php
// $vowels = array("a","e","i","o","u","A","E","I","O","U");
$WordEntered = $_POST['words'];
$thewordarray = explode(" ", $WordEntered);
$phoneticinventory = array();

if (isset($WordEntered)) {
echo "You entered these words:";

echo "<ul>";
for ($i = 0;$i < count($thewordarray);$i++)
{
  if (strlen(trim($thewordarray[$i])) != 0) {
  	 echo "<li>" . $thewordarray[$i]  ."</li>";
  	}
  	$individualcharacters = str_split($thewordarray[$i]) ;
  	//while looping through the words, let's start a new loop
  	//that will go through each of the caracters
  	//echo print_r($individualcharacters) . "<br />";
  		for ($j=0;$j< count($individualcharacters);$j++)
  			{
  				if (in_array($individualcharacters[$j], $phoneticinventory)==FALSE) 
  				{ 
  				array_push($phoneticinventory, $individualcharacters[$j]);
  				}
  				
  			}
  $secretstring .= "#". $thewordarray[$i] . "#";		
  }
echo "</ul>";




echo "Of these words, here is the phonetic inventory: <br /> Click on one (or more) to see the surrounding environments.<br />Click again to remove it from the list of environments."  ;

echo "<div class='selector'><ul>";
//print the array
for ($k=0;$k<count($phoneticinventory);$k++)
{
	echo "<li><input type=button value='".$phoneticinventory[$k]."' onclick='showenv(this.value);'/></li>";
}
echo "</ul></div>";

//echo "<br />";
//now, to deal with the secret string, a few things must happen:
// !1. slice three elements at a time.
//2. store it in the respecteive array, depending on wat array[1] is.
	$vab = 0;
	$vab3 = $vab + 3;
	for ($vab = 0; $vab <strlen($secretstring) ; $vab++)
	{
		$localenvironment = substr($secretstring, $vab , $vab3);
		$indexer = $localenvironment[1];
		${envarray . $indexer} .= "," . $localenvironment;
		
	}	


echo "<br />";
// now we need a loop that will print each element of $phoneticinventory
//in header tags, and its accompanying environments
	for ($count=0; $count < count($phoneticinventory);$count++)
		{
			$temp = $phoneticinventory[$count];
			//echo "<strong>".$temp."</strong><br />";
			$foobar =  ${envarray . $temp};
			$foobars = explode(",", $foobar);
			//echo "<h1>". $foobar[0] ."</h1>";
			
			echo "<div id='div_" . $temp . "' style='display:none;float:left;'>";
			echo "<table border=0 cellpadding=10>";
			echo "<th colspan='3'>".$temp."</th>";
				for ($anothercounter = 1; $anothercounter < count($foobars); $anothercounter++)
					{
						$foobarss = str_split($foobars[$anothercounter]); //each one of these should be in atd tag
						//echo $foobars[$anothercounter] . "<br />";
						echo "<tr>";
							echo "<td>".$foobarss[0]."</td>";
							echo "<td>___</td>";
							echo "<td>".$foobarss[2]."</td>";
						echo "</tr>";
					}
			echo "</table>";
			echo "</div>";
		}
		}


?>
<p>&nbsp;</p>

</body>

</html>




